package com.example.security_demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.security_demo.dao.UserDao;
import com.example.security_demo.pojo.RegisteredUserDto;
import com.example.security_demo.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 *
 * @author zzh
 * @date 2022/5/14
 * @since 1.0
 */
@RestController
@Slf4j
public class UserController {

    @Autowired
    private UserDao userDao;

    @GetMapping("/users/{id}")
    public User getUserById(@PathVariable Long id) {

        log.info("user id is {}", id);
        return userDao.selectOne(new QueryWrapper<User>().eq("user_id", id));
    }

    @PostMapping
    public void register(@RequestBody RegisteredUserDto registeredUserDto) {
        System.out.println(registeredUserDto);
    }
}
